package com.tianyuan.dplrf.ui.activity;

import androidx.appcompat.widget.AppCompatTextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.view.Gravity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.hjq.base.BaseAdapter;
import com.hjq.widget.layout.WrapRecyclerView;
import com.tianyuan.dplrf.R;
import com.tianyuan.dplrf.app.AppActivity;
import com.tianyuan.dplrf.ui.adapter.NczdAdapter;
import com.tianyuan.dplrf.ui.bean.NczdBean;
import com.tianyuan.dplrf.ui.common.SpaceItemDecoration;
import com.tianyuan.dplrf.ui.popup.SharePop2;

import java.util.ArrayList;
import java.util.List;

public class MinencAct extends AppActivity implements View.OnClickListener , BaseAdapter.OnItemClickListener {
    private ImageView img_land_back;
    private TextView tv_title;
    private AppCompatTextView tv_onlinemall;
    private AppCompatTextView tv_wdnc;
    private AppCompatTextView tv_share;
    private AppCompatTextView tv_mine;
    private WrapRecyclerView recycle_content;
    private List<NczdBean> zdList;
    private NczdAdapter mAdapter;
    @Override
    protected int getLayoutId() {
        return R.layout.activity_minenc;
    }

    @Override
    protected void initView() {

        img_land_back = findViewById(R.id.img_land_back);
        tv_title = findViewById(R.id.tv_title);
        tv_onlinemall = findViewById(R.id.tv_onlinemall);
        tv_wdnc = findViewById(R.id.tv_wdnc);
        tv_share = findViewById(R.id.tv_share);
        tv_mine = findViewById(R.id.tv_mine);
        recycle_content = findViewById(R.id.recycle_content);

        tv_onlinemall.setOnClickListener(this);
        tv_wdnc.setOnClickListener(this);
        tv_share.setOnClickListener(this);
        tv_mine.setOnClickListener(this);
        img_land_back.setOnClickListener(this);

        img_land_back.setVisibility(View.GONE);

    }

    @Override
    protected void initData() {
        tv_title.setText("我的农场");
        textdrawableSetting(tv_mine, R.drawable.ic_user,28, Gravity.TOP);
        textdrawableSetting(tv_onlinemall, R.drawable.ic_briefcase_1,28, Gravity.TOP);
        textdrawableSetting(tv_share, R.drawable.ic_share,28, Gravity.TOP);
        textdrawableSetting(tv_wdnc, R.drawable.ic_sunrise,28, Gravity.TOP);

        zdList = new ArrayList<>();
        for (int a = 0; a < 5; a++) {
            NczdBean bean = new NczdBean();

            if (a == 1){
                bean.setId(R.drawable.img_ncj);
                bean.setNcName("养殖A区");
            } else if (a == 2) {
                bean.setId(R.drawable.img_ncj);
                bean.setNcName("养殖B区");
            }else {
                bean.setId(R.drawable.img_sysun);
                bean.setNcName("城市农场" + String.format("%02d", a + 1));
            }

            bean.setDescrip("......");
            zdList.add(bean);
        }
        mAdapter = new NczdAdapter(this, zdList);
        mAdapter.setOnItemClickListener(this);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false);//true 倒转显示
        recycle_content.setLayoutManager(layoutManager);
        recycle_content.addItemDecoration(new SpaceItemDecoration(10));
        recycle_content.setAdapter(mAdapter);

    }

    @Override
    public void onItemClick(RecyclerView recyclerView, View itemView, int position) {
        startActivity(Minenc_jtActivity.class);
    }


    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.tv_onlinemall:
                break;
            case R.id.tv_wdnc:
                startActivity(NczdAct.class);
                break;
            case R.id.tv_share:
                SharePop2.Builder build = new SharePop2.Builder(this);

                build.create().setFullScreen().show();
                break;
            case R.id.tv_mine:
                break;
            case R.id.img_land_back:
                finish();
                break;
        }
    }
}